from flask import Flask
from flask import Blueprint, make_response, jsonify
from flask_cors import CORS
from flask_restplus import Api

from restful.login import login_api


def create_app():
    """初始化工厂函数"""
    app = Flask(__name__)
    api = Api()
    # 跨域处理
    CORS(app, resources={r"/api/*": {"origins": "*"}})
    # 初始化swagger
    api.init_app(app)
    # 注册蓝图
    app.register_blueprint(blueprint=login_api)

    return app
